package com.junsi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;








import com.junsi.bean.Contract;
import com.junsi.bean.Sale;
import com.junsi.mapper.ContractMapper;
import com.junsi.mapper.SaleMapper;
import com.junsi.service.ContractService;
import com.junsi.service.SaleService;
import com.junsi.util.PageUtil;
import com.sun.org.apache.xpath.internal.operations.And;

/**   
  * @文件名: SaleServiceImpl.java 
  * @包名: com.junsi.service.impl 
  * @类名: SaleServiceImpl   
  * @时间: 2017年6月28日 上午9:21:00 2017
  * @作者: 
  * @类功能描述:TODO 请简要描述你的类   
  */
@Service
@Transactional(rollbackFor = Exception.class)
public class ContractServiceImpl implements ContractService {
	
	@Autowired
	private ContractMapper contractMapper;

	@Override
	public boolean save(Contract contract) {
		int result = contractMapper.save(contract);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public boolean deleteById(Integer id) {
		int result = contractMapper.delete(id);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public boolean update(Contract contract){
		int result = contractMapper.update(contract);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public List<Contract> findByAll(String staffs,PageUtil pageUtil) {
		return contractMapper.findByAll(staffs,pageUtil.getEndIndex(),pageUtil.getBeginIndex());
	}

	@Override
	public Contract findByID(Integer id) {
		return contractMapper.findById(id);
	}

	public List<Contract> pageFind(PageUtil pageUtil) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public int findCount(String staff_id) {
		
		return contractMapper.findCount(staff_id);
	}

	@Override
	public boolean deletes(String ids) {
		
		if(ids != null && !ids.equals("")){
			String[] arr = ids.split(",");
			int reuslt = contractMapper.deletes(arr);
			if(reuslt != 0){
				return true;
			}
		}
		return false;
	}

	@Override
	public List<Contract> findByAll(String[] staff_names) {
		
		return contractMapper.findByAlls(staff_names);
	}

	



	

}
